package com.ruoyi.web.controller.system.Fdongbei;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.system.Fdongbei.domain.TbHmd;
import com.ruoyi.system.Fdongbei.domain.TbHmdw;
import com.ruoyi.system.Fdongbei.service.ITbHmdService;
import com.ruoyi.system.Fdongbei.service.ITbHmdwService;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;

import com.ruoyi.common.core.page.TableDataInfo;

/**
 * tb_heimingdan_1Controller
 * 
 * @author ruoyi
 * @date 2025-01-02
 */
@RestController
@RequestMapping("/system/hmd")
public class TbHmdwController extends BaseController
{
    @Autowired
    private ITbHmdwService tbHmdwService;

    /**
     * 查询tb_heimingdan_1列表
     */
//    @PreAuthorize("@ss.hasPermi('system:hmd:list')")
    @GetMapping("/list")
    public TableDataInfo list(TbHmdw tbHmdw)
    {
        startPage();
        List<TbHmdw> list = tbHmdwService.selectTbHmdList(tbHmdw);
        return getDataTable(list);
    }

    /**
     * 导出tb_heimingdan_1列表
     */
    @PreAuthorize("@ss.hasPermi('system:hmd:export')")
    @Log(title = "tb_heimingdan_1", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, TbHmdw tbHmd)
    {
        List<TbHmdw> list = tbHmdwService.selectTbHmdList(tbHmd);
        ExcelUtil<TbHmdw> util = new ExcelUtil<TbHmdw>(TbHmdw.class);
        util.exportExcel(response, list, "tb_heimingdan_1数据");
    }

    /**
     * 获取tb_heimingdan_1详细信息
     */
//    @PreAuthorize("@ss.hasPermi('system:hmd:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(tbHmdwService.selectTbHmdById(id));
    }

    /**
     * 新增tb_heimingdan_1
     */
    @PreAuthorize("@ss.hasPermi('system:hmd:add')")
    @Log(title = "tb_heimingdan_1", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody TbHmdw tbHmd)
    {
        List<TbHmdw> list = tbHmdwService.selectTbHmdList(tbHmd);
        if (list == null || list.isEmpty())
            return toAjax(tbHmdwService.insertTbHmd(tbHmd));
        else return error("黑名单中已存在此车号！");
    }

    /**
     * 修改tb_heimingdan_1
     */
    @PreAuthorize("@ss.hasPermi('system:hmd:edit')")
    @Log(title = "tb_heimingdan_1", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody TbHmdw tbHmd)
    {
        return toAjax(tbHmdwService.updateTbHmd(tbHmd));
    }

    /**
     * 删除tb_heimingdan_1
     */
    @PreAuthorize("@ss.hasPermi('system:hmd:remove')")
    @Log(title = "tb_heimingdan_1", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(tbHmdwService.deleteTbHmdByIds(ids));
    }
}
